class Solution {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if (matrix == null || matrix.length == 0 || matrix[0].length == 0) {
            return false;
        } 
        int row = 0;
        int column = matrix[0].length - 1;
        while(row < matrix.length && column >= 0) {
            int t = matrix[row][column];
            if(t > target) {
                column--;
            }
            else if(t < target) {
                row++;
            }
            else {
                return true;
            }
        }
        return false;
    }
}